/**
 * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package vn.com.fis.portal.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import vn.com.fis.portal.model.CategoryVideoEntry;
import vn.com.fis.portal.model.CategoryVideoEntryModel;
import vn.com.fis.portal.model.CategoryVideoEntrySoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.List;

/**
 * The base model implementation for the CategoryVideoEntry service. Represents a row in the &quot;TBL_CATEGORY_VIDEO&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link vn.com.fis.portal.model.CategoryVideoEntryModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link CategoryVideoEntryImpl}.
 * </p>
 *
 * @author loind
 * @see CategoryVideoEntryImpl
 * @see vn.com.fis.portal.model.CategoryVideoEntry
 * @see vn.com.fis.portal.model.CategoryVideoEntryModel
 * @generated
 */
@JSON(strict = true)
public class CategoryVideoEntryModelImpl extends BaseModelImpl<CategoryVideoEntry>
	implements CategoryVideoEntryModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a category video entry model instance should use the {@link vn.com.fis.portal.model.CategoryVideoEntry} interface instead.
	 */
	public static final String TABLE_NAME = "TBL_CATEGORY_VIDEO";
	public static final Object[][] TABLE_COLUMNS = {
			{ "categoryViceoId", Types.BIGINT },
			{ "categoryId", Types.BIGINT },
			{ "videoId", Types.BIGINT }
		};
	public static final String TABLE_SQL_CREATE = "create table TBL_CATEGORY_VIDEO (categoryViceoId LONG not null primary key,categoryId LONG,videoId LONG)";
	public static final String TABLE_SQL_DROP = "drop table TBL_CATEGORY_VIDEO";
	public static final String ORDER_BY_JPQL = " ORDER BY categoryVideoEntry.categoryViceoId ASC";
	public static final String ORDER_BY_SQL = " ORDER BY TBL_CATEGORY_VIDEO.categoryViceoId ASC";
	public static final String DATA_SOURCE = "liferayDataSource";
	public static final String SESSION_FACTORY = "liferaySessionFactory";
	public static final String TX_MANAGER = "liferayTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.vn.com.fis.portal.model.CategoryVideoEntry"),
			true);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.vn.com.fis.portal.model.CategoryVideoEntry"),
			true);
	public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.column.bitmask.enabled.vn.com.fis.portal.model.CategoryVideoEntry"),
			true);
	public static long CATEGORYID_COLUMN_BITMASK = 1L;
	public static long VIDEOID_COLUMN_BITMASK = 2L;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static CategoryVideoEntry toModel(CategoryVideoEntrySoap soapModel) {
		CategoryVideoEntry model = new CategoryVideoEntryImpl();

		model.setCategoryViceoId(soapModel.getCategoryViceoId());
		model.setCategoryId(soapModel.getCategoryId());
		model.setVideoId(soapModel.getVideoId());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<CategoryVideoEntry> toModels(
		CategoryVideoEntrySoap[] soapModels) {
		List<CategoryVideoEntry> models = new ArrayList<CategoryVideoEntry>(soapModels.length);

		for (CategoryVideoEntrySoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.vn.com.fis.portal.model.CategoryVideoEntry"));

	public CategoryVideoEntryModelImpl() {
	}

	public long getPrimaryKey() {
		return _categoryViceoId;
	}

	public void setPrimaryKey(long primaryKey) {
		setCategoryViceoId(primaryKey);
	}

	public Serializable getPrimaryKeyObj() {
		return new Long(_categoryViceoId);
	}

	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	public Class<?> getModelClass() {
		return CategoryVideoEntry.class;
	}

	public String getModelClassName() {
		return CategoryVideoEntry.class.getName();
	}

	@JSON
	public long getCategoryViceoId() {
		return _categoryViceoId;
	}

	public void setCategoryViceoId(long categoryViceoId) {
		_columnBitmask = -1L;

		_categoryViceoId = categoryViceoId;
	}

	@JSON
	public long getCategoryId() {
		return _categoryId;
	}

	public void setCategoryId(long categoryId) {
		_columnBitmask |= CATEGORYID_COLUMN_BITMASK;

		if (!_setOriginalCategoryId) {
			_setOriginalCategoryId = true;

			_originalCategoryId = _categoryId;
		}

		_categoryId = categoryId;
	}

	public long getOriginalCategoryId() {
		return _originalCategoryId;
	}

	@JSON
	public long getVideoId() {
		return _videoId;
	}

	public void setVideoId(long videoId) {
		_columnBitmask |= VIDEOID_COLUMN_BITMASK;

		if (!_setOriginalVideoId) {
			_setOriginalVideoId = true;

			_originalVideoId = _videoId;
		}

		_videoId = videoId;
	}

	public long getOriginalVideoId() {
		return _originalVideoId;
	}

	public long getColumnBitmask() {
		return _columnBitmask;
	}

	@Override
	public CategoryVideoEntry toEscapedModel() {
		if (_escapedModelProxy == null) {
			_escapedModelProxy = (CategoryVideoEntry)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelProxyInterfaces,
					new AutoEscapeBeanHandler(this));
		}

		return _escapedModelProxy;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		if (_expandoBridge == null) {
			_expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
					CategoryVideoEntry.class.getName(), getPrimaryKey());
		}

		return _expandoBridge;
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		getExpandoBridge().setAttributes(serviceContext);
	}

	@Override
	public Object clone() {
		CategoryVideoEntryImpl categoryVideoEntryImpl = new CategoryVideoEntryImpl();

		categoryVideoEntryImpl.setCategoryViceoId(getCategoryViceoId());
		categoryVideoEntryImpl.setCategoryId(getCategoryId());
		categoryVideoEntryImpl.setVideoId(getVideoId());

		categoryVideoEntryImpl.resetOriginalValues();

		return categoryVideoEntryImpl;
	}

	public int compareTo(CategoryVideoEntry categoryVideoEntry) {
		int value = 0;

		if (getCategoryViceoId() < categoryVideoEntry.getCategoryViceoId()) {
			value = -1;
		}
		else if (getCategoryViceoId() > categoryVideoEntry.getCategoryViceoId()) {
			value = 1;
		}
		else {
			value = 0;
		}

		if (value != 0) {
			return value;
		}

		return 0;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}

		CategoryVideoEntry categoryVideoEntry = null;

		try {
			categoryVideoEntry = (CategoryVideoEntry)obj;
		}
		catch (ClassCastException cce) {
			return false;
		}

		long primaryKey = categoryVideoEntry.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
		CategoryVideoEntryModelImpl categoryVideoEntryModelImpl = this;

		categoryVideoEntryModelImpl._originalCategoryId = categoryVideoEntryModelImpl._categoryId;

		categoryVideoEntryModelImpl._setOriginalCategoryId = false;

		categoryVideoEntryModelImpl._originalVideoId = categoryVideoEntryModelImpl._videoId;

		categoryVideoEntryModelImpl._setOriginalVideoId = false;

		categoryVideoEntryModelImpl._columnBitmask = 0;
	}

	@Override
	public CacheModel<CategoryVideoEntry> toCacheModel() {
		CategoryVideoEntryCacheModel categoryVideoEntryCacheModel = new CategoryVideoEntryCacheModel();

		categoryVideoEntryCacheModel.categoryViceoId = getCategoryViceoId();

		categoryVideoEntryCacheModel.categoryId = getCategoryId();

		categoryVideoEntryCacheModel.videoId = getVideoId();

		return categoryVideoEntryCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{categoryViceoId=");
		sb.append(getCategoryViceoId());
		sb.append(", categoryId=");
		sb.append(getCategoryId());
		sb.append(", videoId=");
		sb.append(getVideoId());
		sb.append("}");

		return sb.toString();
	}

	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append("vn.com.fis.portal.model.CategoryVideoEntry");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>categoryViceoId</column-name><column-value><![CDATA[");
		sb.append(getCategoryViceoId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>categoryId</column-name><column-value><![CDATA[");
		sb.append(getCategoryId());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>videoId</column-name><column-value><![CDATA[");
		sb.append(getVideoId());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = CategoryVideoEntry.class.getClassLoader();
	private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
			CategoryVideoEntry.class
		};
	private long _categoryViceoId;
	private long _categoryId;
	private long _originalCategoryId;
	private boolean _setOriginalCategoryId;
	private long _videoId;
	private long _originalVideoId;
	private boolean _setOriginalVideoId;
	private transient ExpandoBridge _expandoBridge;
	private long _columnBitmask;
	private CategoryVideoEntry _escapedModelProxy;
}